package com.goldsprite.gameframeworks.shaders;

import com.badlogic.gdx.graphics.g2d.Batch;

public class LightBlendShader extends BaseShader {
    private int u_sceneTextureLocation;
    private int u_ambientTextureLocation;
    private int u_lightTextureLocation;
    private int u_lightIntensityLocation;
	private int uLightIntensityCompressValLocation;

	// 光源贡献度控制
    private float lightIntensity = 50f;
	public static final float lightIntensityCompressVal = 100.0f;//光源强度数据压缩

    public LightBlendShader() {
        super("shaders/light_blend.vert", "shaders/light_blend.frag");
    }

    @Override
    protected void initUniforms() {
        u_sceneTextureLocation = getUniformLocation("u_sceneTexture");
        u_ambientTextureLocation = getUniformLocation("u_ambientTexture");
        u_lightTextureLocation = getUniformLocation("u_lightTexture");
        u_lightIntensityLocation = getUniformLocation("u_lightIntensity");
		uLightIntensityCompressValLocation = shaderProgram.getUniformLocation("u_lightIntensityCompressVal");
    }

    @Override
    public void setUniforms() {
        // 设置纹理单元
        shaderProgram.setUniformi(u_sceneTextureLocation, 0);
        shaderProgram.setUniformi(u_ambientTextureLocation, 1);
        shaderProgram.setUniformi(u_lightTextureLocation, 2);
        shaderProgram.setUniformf(u_lightIntensityLocation, lightIntensity);
		shaderProgram.setUniformf(uLightIntensityCompressValLocation, lightIntensityCompressVal);
    }

    public void setLightIntensity(float intensity) {
        this.lightIntensity = intensity;
    }
}
